import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getAllCategoryListApi } from '@/apis/category'
import type { CategoryType } from '@/apis/components/categoryType'

export const useCategoryStore = defineStore(
  'category',
  () => {
    const categoryList = ref<CategoryType[]>()

    // 获取全部分类
    const getAllCategoryList = async () => {
      const res = await getAllCategoryListApi()
      categoryList.value = res.data.result
    }
    getAllCategoryList()

    return { categoryList }
  },
  // {
  //   persist: true,
  // },
)
